Intro Bite 08. Loop over a dict of namedtuples calculating a total score
Login and get codingIn this Bite you calculate the total amount of points earned with Ninja Belts by accessing the given
ninja_beltsdict.You learn how to access score and ninjas (= amount of belt owners) from no less than a
namedtuple(if you're new to them, check out the basicPointexample in the docs).Why a namedtuple, you did not even mention a tuple yet?!
Good point, well in our Bites we might actually use them even more so let's get to know them here (if you have a free evening read up on the
collectionsmodule as well and thank us later).The function returns the total score
int. You learn to write generic code because we test for an updatedninja_beltsdict as well, see the TESTS tab.
3001 out of 3122 users completed this Bite.
Will you be the 3002nd person to crack this Bite?
Resolution time: ~36 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.62 on a 1-10 difficulty scale.
» Up for a challenge? 💪